<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php JHTML::_('behavior.tooltip'); ?>
<?php JHTML::_('behavior.modal'); ?>

<form action="index.php" method="post" name="adminForm">
<table>
<tr>
        <td align="left" width="100%">
                <?php echo JText::_( 'Filter' ); ?>:
                <input type="text" name="search" id="search" value="<?php echo $this->search ;?>" class="text_area" onchange="document.adminForm.submit();" />
                <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
                <button onclick="document.getElementById('search').value='';this.form.getElementById('filter_catid').value='0';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
        </td>
        <td nowrap="nowrap">
                <?php
                        echo $this->catid;
                        echo $this->state;
                ?>
        </td>
</tr>
</table>
<div id="editcell">
        <table class="adminlist">
        <thead>
                <tr>
                        <th width="5">
                                <?php echo JText::_( 'ID' ); ?>
                        </th>
                        <th width="20">
                                <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
                        </th>
                        <th align="left">
                                <?php echo JHTML::_('grid.sort',  'Title', 'title', $this->order_Dir , $this->order  ); ?>
                        </th>
                        <th class="title" width="40%" nowrap="nowrap">
                                <?php echo JText::_('Description'); ?>
                        </th>
                        <th width="5%" nowrap="nowrap">
                                <?php echo JHTML::_('grid.sort',  'Published', 'published', $this->order_Dir, $this->order ); ?>
                        </th>
                        <th width="10%" nowrap="nowrap">
                                <?php echo JHTML::_('grid.sort',  'Subscribers', 'subscribers', $this->order_Dir, $this->subscribers ); ?>
                        </th>
                        <th width="10%"  class="title">
                                <?php echo JHTML::_('grid.sort',  'Letters', 'letters', $this->order_Dir, $this->letters ); ?>
                        </th>
                        <th width="10%">
                                <?php echo JHTML::_('grid.sort',  'Last Sent', 'last_sent', $this->order_Dir, $this->last_sent ); ?>
                        </th>
                </tr>
        </thead>
        <tfoot>
                <tr>
                        <td colspan="9">
                                <?php echo $this->pagination->getListFooter(); ?>
                        </td>
                </tr>
        </tfoot>
        <tbody>
        <?php
        $k = 0;
        for ($i=0, $n=count( $this->data ); $i < $n; $i++)
        {
                $row = &$this->data[$i];

                $link   = 'index.php?option=com_letterman&view=campaign&layout=form&amp;cid[]=' . $row->id ;

                $checked        = JHTML::_('grid.checkedout',   $row, $i );
                $published      = JHTML::_('grid.published', $row, $i );

                $ordering = ($this->lists['order'] == 'a.ordering');
                ?>
                <tr class="<?php echo "row$k"; ?>">
                        <td>
                                <?php echo $this->pagination->getRowOffset( $i ); ?>
                        </td>
                        <td>
                                <?php echo $checked; ?>
                        </td>
                        <td>
                                <?php
                                //if (  JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) {
                                //      echo $row->title;
                                //} else {
                                ?>
                                <span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Campaign' );?>::<?php echo $row->title; ?>">
                                        <a  class="modal" href="<?php echo $link; ?>"  rel="{handler: 'iframe', size: {x: 640, y: 480}}" >
                                                <?php echo $row->title; ?></a></span>
                                <?php
                                //}
                                ?>
                        </td>
                        <td align="left">
                                <?php echo $row->description; ?>
                                
                        </td>
                        <td align="center">
                                <?php echo $published;?>
                        </td>
                        <td align="center">
                                <?php echo $row->subscribers; ?>
                        </td>
                        <td align="center">
                                <?php echo $row->letters; ?>
                        </td>
                        <td align="center">
                                <?php echo $row->last_sent; ?>
                        </td>
                </tr>
                <?php
                $k = 1 - $k;
        }
        ?>
        </tbody>
        </table>
</div>

	<input type="hidden" name="option" value="com_letterman" />
        <input type="hidden" name="view" value="campaigns" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->order ; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->order_Dir ; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>